<%@page import="java.util.*"%>
<%@page import="java.text.*"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %> 
<%
    String path = request.getContextPath(); 
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+path+ "/"; 
     
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
    <head>
    <style type="text/css">
    a{ text-decoration:none} 
    </style>
        <meta charset="utf-8">
        <base href="<%=basePath%>">
        <title>
             VIP优惠设置
        </title>
        <meta name="renderer" content="webkit">
        <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
        <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
        <meta name="apple-mobile-web-app-status-bar-style" content="black">
        <meta name="apple-mobile-web-app-capable" content="yes">
        <meta name="format-detection" content="telephone=no">
        <link rel="stylesheet" href="css/x-admin.css" media="all">
    </head>
    
    <body>
       <fieldset class="layui-elem-field">
				  <legend>vip信息</legend>
				  <div class="layui-field-box">
				      <form class="layui-form layui-form-pane" action="">
				          <input type="hidden" id="gId" value="${vipInfo.gId}">
						  <div class="layui-form-item">
						    <label class="layui-form-label" style="width: 150px">VIP名称</label> 
						    <div class="layui-input-inline">
						      <input type="text" name="vip" lay-verify="required" autocomplete="off" class="layui-input" value="${vipInfo.gVipName}">
						    </div>
						  </div>
						  
						  <div class="layui-form-item">
						    <label class="layui-form-label" style="width: 150px">设置单个视频折扣值(%)</label>
						    <div class="layui-input-inline">
						      <input type="text" name="singleCourseDiscount" id="singleCourseDiscount" lay-verify="required" autocomplete="off" class="layui-input" value="${vipInfo.singleCourseDiscount}">
						    </div>
						  </div>
						  
						  <div class="layui-form-item">
						    <label class="layui-form-label" style="width: 150px">设置一般课程折扣值(%)</label>
						    <div class="layui-input-inline">
						      <input type="text" name="generalCourseDiscount" id="generalCourseDiscount" lay-verify="required" autocomplete="off" class="layui-input" value="${vipInfo.generalCourseDiscount}">
						    </div>
						  </div>
						  
						  <div class="layui-form-item">
						    <label class="layui-form-label" style="width: 150px">设置知识体系折扣值(%)</label>
						    <div class="layui-input-inline">
						      <input type="text" name="knowledgeCourseDiscount" id="knowledgeCourseDiscount" lay-verify="required" autocomplete="off" class="layui-input" value="${vipInfo.knowledgeCourseDiscount}">
						    </div>
						  </div>
						  
						  <div class="layui-form-item">
						    <label class="layui-form-label" style="width: 150px">设置职业方向折扣值(%)</label>
						    <div class="layui-input-inline">
						      <input type="text" name="jobCourseDiscount" id="jobCourseDiscount" lay-verify="required" autocomplete="off" class="layui-input" value="${vipInfo.jobCourseDiscount}">
						    </div>
						  </div>
						  
						  <div class="layui-form-item">
						    <label class="layui-form-label" style="width: 150px">设置打包课程折扣值(%)</label>
						    <div class="layui-input-inline">
						      <input type="text" name="packCourseDiscount" id="packCourseDiscount" lay-verify="required" autocomplete="off" class="layui-input" value="${vipInfo.packCourseDiscount}">
						    </div>
						  </div>
				
                  </form>
				  </div>
				  
				  
		      <div class="layui-form-item">
		            <label for="L_repass" class="layui-form-label">
		            </label>
		             <button type="submit"   onclick="save()"  class="layui-btn" >确认</button>
		             <button  class="layui-btn" onclick="parent.location.reload()">
		                                                                   取消
		            </button>
		       </div>
      </fieldset>
        <script src="js/jquery-3.2.1.min.js"></script>
        <script src="js/common2.js"></script>
        <script src="lib/layui/layui.js" charset="utf-8">
        </script>
        <script src="js/x-layui.js" charset="utf-8">
      
        </script>
        <script>
            layui.use(['form','layer'], function(){
                $ = layui.jquery;
              var form = layui.form()
              ,layer = layui.layer;
 
            });
            
        </script>
        <script>
        var _hmt = _hmt || [];
        (function() {
          var hm = document.createElement("script");
          hm.src = "https://hm.baidu.com/hm.js?b393d153aeb26b46e9431fabaf0f6190";
          var s = document.getElementsByTagName("script")[0]; 
          s.parentNode.insertBefore(hm, s);
        })();
        
        
        function save() {
			 var gId = $("#gId").val();
			 var singleCourseDiscount =	$("#singleCourseDiscount").val();
			 var generalCourseDiscount =	$("#generalCourseDiscount").val();
			 var knowledgeCourseDiscount =	$("#knowledgeCourseDiscount").val();
			 var jobCourseDiscount =	$("#jobCourseDiscount").val();
			 var packCourseDiscount =	$("#packCourseDiscount").val();
			
  		   	 if(singleCourseDiscount == null||singleCourseDiscount=="") {
  		   		layer.msg('单个视频折扣值不能为空!',{icon:2,time:2000});
  				  return ;
  		   	 }
  		     var re = /^[1-9]+[0-9]*]*$/;  
  		     if (!re.test(singleCourseDiscount)) {  
  			     layer.msg('单个视频折扣值输入格式不正确!',{icon:2,time:2000});
			     return ;
  	         }  
  		   
  		     if(generalCourseDiscount == null||generalCourseDiscount=="") {
		   		layer.msg('一般课程折扣值不能为空!',{icon:2,time:2000});
				  return ;
		   	 }
		     var re = /^[1-9]+[0-9]*]*$/;  
		     if (!re.test(generalCourseDiscount)) {  
			    layer.msg('一般课程折扣值输入格式不正确!',{icon:2,time:2000});
			    return ;
	         }  
		     
		     if(knowledgeCourseDiscount == null||knowledgeCourseDiscount=="") {
			   		layer.msg('知识体系折扣值不能为空!',{icon:2,time:2000});
					  return ;
			 }
		     var re = /^[1-9]+[0-9]*]*$/;  
		     if (!re.test(knowledgeCourseDiscount)) {  
			    layer.msg('知识体系折扣值输入格式不正确!',{icon:2,time:2000});
			    return ;
	         }  
		     
		     if(jobCourseDiscount == null||jobCourseDiscount=="") {
			   		layer.msg('职业方向折扣值不能为空!',{icon:2,time:2000});
					  return ;
			 }
		     var re = /^[1-9]+[0-9]*]*$/;  
		     if (!re.test(jobCourseDiscount)) {  
			    layer.msg('职业方向折扣值输入格式不正确!',{icon:2,time:2000});
			    return ;
	         }  
		     
		     if(packCourseDiscount == null||packCourseDiscount=="") {
			   		layer.msg('打包课程折扣值不能为空!',{icon:2,time:2000});
					  return ;
			 }
		     var re = /^[1-9]+[0-9]*]*$/;  
		     if (!re.test(packCourseDiscount)) {  
			    layer.msg('打包课程折扣值输入格式不正确!',{icon:2,time:2000});
			    return ;
	         }  
			 var  data = {"gId":gId,"singleCourseDiscount":singleCourseDiscount,"generalCourseDiscount":generalCourseDiscount,
					 "knowledgeCourseDiscount":knowledgeCourseDiscount,"jobCourseDiscount":jobCourseDiscount,"packCourseDiscount":packCourseDiscount}
	         $.ajax({
	             type: "post",
	             url: "course/setVipDiscont",
	             data: JSON.stringify(data),
	             contentType:"application/json;charset=UTF-8", 
	             dataType:"json",
	             success: function(data){    
	           	    if(data.code==200){
	           		    layer.msg(data.msg,{icon:1,time:4000});		
	           		    parent.location.reload()
					} else {
							var txt = data.msg;
							window.wxc.xcConfirm(txt,
									window.wxc.xcConfirm.typeEnum.info);
					}
	             }
			});
		}
        </script>
    </body>


</html>